package com.study.www.service.task;

import com.alibaba.fastjson.JSONObject;
import com.study.www.model.Config;
import com.study.www.model.Logger;
import com.study.www.model.TestTable;
import com.study.www.model.mapper.LoggerRepository;
import com.study.www.model.mapper.TestTableRepository;
import com.sun.corba.se.spi.ior.ObjectKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.DateUtils;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ScheduleTask: 定时任务的服务
 *
 * @date :  2018/2/23    16:29
 **/
@Service
@Slf4j
public class ScheduleTask {

    @Autowired
    TestTableRepository tableRepository;

    public void test1() {
        LocalDateTime time = LocalDateTime.now();
        log.warn("good!good!study!:当前时间=" + time.getHour() + "时" + time.getMinute() + "分" + time.getSecond() + "秒"+System.currentTimeMillis());
    }

    public void test2(String paramKey1,String paramKey2) {
        LocalDateTime time = LocalDateTime.now();
        log.warn("day!day!UP!!:当前时间=" + time.getHour() + "时" + time.getMinute() + "分" + time.getSecond() + "秒");
        log.warn("paramKey1:"+paramKey1+"paramKey2:"+paramKey2);
    }

    public void test3(String param1, Integer param2, Boolean param3, Byte param4, Short param5, Double param6,
                      BigDecimal param7, List<String> param8, Map<String,Object> param9, Config param10) {
        LocalDateTime time = LocalDateTime.now();
        /***************************  START *********************/
        log.warn("hello!hello!UP!!:当前时间=" + time.getHour() + "时" + time.getMinute() + "分" + time.getSecond() + "秒"+System.currentTimeMillis());
        log.warn("param1:"+param1);
        log.warn("param2:"+param2);
        log.warn("param3:"+param3);
        log.warn("param4:"+param4);
        log.warn("param5:"+param5);
        log.warn("param6:"+param6);
        log.warn("param7:"+param7);
        log.warn("param8:"+ JSONObject.toJSONString(param8));
        log.warn("param9:"+JSONObject.toJSONString(param9));
        log.warn("param10:"+JSONObject.toJSONString(param10));
        /***************************  END ***********************/
    }


    public void test4(String name) {
        TestTable testTable = new TestTable();
        testTable.setName(name);
        LocalDateTime time = LocalDateTime.now();
        testTable.setTime(time.getHour() + "时" + time.getMinute() + "分" + time.getSecond() + "秒");
        tableRepository.save(testTable);
    }
}
